package net.zm123.sync;

import com.nfk.grpc.MyServiceGrpc;
import com.nfk.grpc.MyServiceOuterClass;
import io.grpc.stub.StreamObserver;

public class RpcSyncServerImpl extends MyServiceGrpc.MyServiceImplBase {
    @Override
    public void actionMethod(MyServiceOuterClass.ActionRequest request, StreamObserver<MyServiceOuterClass.ActionResponse> responseObserver) {
        //super.actionMethod(request, responseObserver);//这里一定要注释
        MyServiceOuterClass.ActionResponse response = this.doGetResponse(request);
        responseObserver.onNext(response);
        responseObserver.onCompleted();
    }

    private MyServiceOuterClass.ActionResponse doGetResponse(MyServiceOuterClass.ActionRequest request){
        MyServiceOuterClass.ActionResponse response
                = MyServiceOuterClass.ActionResponse.newBuilder()
                .setStatus("1")
                .setMessage("hello")
                .build();
        return response;
    }
}
